package com.suoyue.store.service.impl;

import com.suoyue.store.entity.Log;
import com.suoyue.store.mapper.LogMapper;
import com.suoyue.store.service.ex.ServiceException;
import com.suoyue.store.service.iLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements iLogService {
    @Autowired
    LogMapper logMapper;
    @Override
    public List<Log> getLogByUid(Integer uid) {
        List<Log> result=logMapper.getLogByUid(uid);
        if(result.size()==0){
            throw new ServiceException("用户暂无记录");
        }
        return result;
    }

    @Override
    public Integer insertBrowseLog(Integer uid, Integer pid) {
        Integer row=logMapper.insertBrowseLog(uid,pid);
        if(row!=1){
            throw new ServiceException("插入数据失败");
        }
        return row;
    }

    @Override
    public Integer insertBuyLog(Integer uid, Integer pid) {
        Integer row=logMapper.insertBuyLog(uid,pid);
        if(row!=1){
            throw new ServiceException("插入数据失败");
        }
        return row;
    }
}
